﻿import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3


import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import Qt.labs.platform 1.0

import "./control"

Pane {
    property int nTab: 0

    id: home
    padding: 0
    background: Rectangle
                {
                    color:"#444444"
                }
    RowLayout {
        spacing: 0
        anchors.fill: parent

        Pane {
            id: leftNav
            padding: 0
            Layout.minimumWidth: 90
            Layout.fillHeight:true

            background: Rectangle
                        {
                            color:"#292f38"
                        }

            ColumnLayout {
                spacing: 0
                anchors.fill: parent

                IconTextMiniBtn {
                    id: tab1
                    strText: "基本设置"
                    icon: "\uf031"
                    bHighlighted: 0 == home.nTab
                    Layout.fillWidth: true
                    Layout.minimumHeight: 40
                    onClicked: {
                        home.nTab = 0;
                    }
                }

                IconTextMiniBtn {
                    id: tab2
                    strText: "转发设置"
                    icon: "\uf036"
                    bHighlighted: 1 == home.nTab
                    Layout.fillWidth: true
                    Layout.minimumHeight: 40

                    onClicked: {
                        home.nTab = 1;
                    }
                }

                IconTextMiniBtn {
                    id: tab3
                    strText: "用户设置"
                    icon: "\uf249"
                    bHighlighted: 2 == home.nTab
                    Layout.fillWidth: true
                    Layout.minimumHeight: 40
                    onClicked: {
                        home.nTab = 2;
                    }
                }

                IconTextMiniBtn {
                    id: tab4
                    strText: "其他设置"
                    icon: "\uf055"
                    bHighlighted: 3 == home.nTab
                    Layout.fillWidth: true
                    Layout.minimumHeight: 40
                    onClicked: {
                        home.nTab = 3;
                    }
                }

                Label {
                    Layout.fillHeight: true
                }
            }

            function activeText() {
                switch(home.nTab)
                {
                case 0:
                    return tab1.strText;
                case 1:
                    return tab2.strText;
                case 2:
                    return tab3.strText;
                case 3:
                    return tab4.strText;
                }

            }
        }

        ColumnLayout {
            property int nSelGrid: 0

            id: configPane
            spacing: 20

            Layout.fillWidth: true
            Layout.margins: 20

            RowLayout {
                spacing: 20
                Layout.fillWidth: true
                Text {
                  text: "主页"
                  color: "#dcdcdc"
                  horizontalAlignment: Label.AlignRight
                  verticalAlignment: Label.AlignTop
                  Layout.minimumWidth: 150
                  Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                  font.bold: true
                }

                ColumnLayout {
                  ExclusiveGroup { id: radioGroup }
                  TRadioButton { text: "网址大全";  exclusiveGroup: radioGroup }
                  TRadioButton { text: "我的最爱"; exclusiveGroup: radioGroup }
                  TRadioButton { text: "空白页"; exclusiveGroup: radioGroup; checked: true }
                }

                Item {
                    Layout.fillWidth: true
                }
            }

            RowLayout {
                spacing: 20
                Layout.fillWidth: true
                Text {
                  text: "界面设置"
                  color: "#dcdcdc"
                  horizontalAlignment: Label.AlignRight
                  verticalAlignment: Label.AlignTop
                  Layout.minimumWidth: 150
                  Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                  font.bold: true
                }

                ColumnLayout {
                    TCheckBox { text: "显示头像"; checked: true }
                    TCheckBox { text: "显示菜单栏"; checked: true }
                    TCheckBox { text: "显示工具栏"; checked: true }
                    TCheckBox { text: "显示扩展栏" }
                    TCheckBox { text: "显示任务栏"; checked: true }
                    TCheckBox { text: "显示侧边栏" }
                }

                Item {
                    Layout.fillWidth: true
                }
            }

            RowLayout {
                spacing: 20
                Layout.fillWidth: true
                Text {
                  text: "文件下载"
                  color: "#dcdcdc"
                  horizontalAlignment: Label.AlignRight
                  verticalAlignment: Label.AlignTop
                  Layout.minimumWidth: 150
                  Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                  font.bold: true
                }

                ColumnLayout {
                    RowLayout {
                        spacing: 20
                        Layout.fillWidth: true
                        Text {
                          text: "默认下载目录"
                          color: "#dcdcdc"
                          horizontalAlignment: Label.AlignLeft
                          verticalAlignment: Label.AlignTop
                          Layout.minimumWidth: 80
                          Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                        }

                        ColumnLayout {
                          ExclusiveGroup { id: radioGroup2 }
                          TRadioButton { text: "使用上次目录";  exclusiveGroup: radioGroup2; checked: true }

                          RowLayout {
                              spacing: 6
                              TRadioButton { id: customDir; text: "指定目录"; exclusiveGroup: radioGroup2 }
                              TextField { text: folderDialog.folder; enabled: customDir.checked; readOnly: true; Layout.fillWidth: true; z: 1 }
                              Button {
                                  text: "浏览";
                                  enabled: customDir.checked
                                  onClicked: {
                                      folderDialog.open()
                                  }
                              }
                          }
                        }

                        Item {
                            Layout.fillWidth: true
                        }
                    }

                    RowLayout {
                        spacing: 20
                        Layout.fillWidth: true
                        Text {
                          text: "默认下载方式"
                          color: "#dcdcdc"
                          horizontalAlignment: Label.AlignLeft
                          verticalAlignment: Label.AlignTop
                          Layout.minimumWidth: 80
                          Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                        }

                        ComboBox {
                            editable: true
                            Layout.minimumWidth: 160
                            model: ListModel {
                                id: listModel
                                ListElement { text: "IDM" }
                                ListElement { text: "迅雷" }
                                ListElement { text: "IE" }
                                ListElement { text: "系统下载" }
                            }
                        }

                        Item {
                            Layout.fillWidth: true
                        }
                    }

                    TCheckBox { text: "启动后自动执行上次未完成任务"; checked: true }
                    TCheckBox { text: "每次下载前询问文件保存位置"; checked: true }
                    TCheckBox { text: "下载完成后自动打开"; }
                }

                Item {
                    Layout.fillWidth: true
                }
            }

            RowLayout {
                spacing: 20
                Layout.fillWidth: true
                Text {
                  text: "系统设置"
                  color: "#dcdcdc"
                  horizontalAlignment: Label.AlignRight
                  verticalAlignment: Label.AlignTop
                  Layout.minimumWidth: 150
                  Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                  font.bold: true
                }

                ColumnLayout {
                    RowLayout {
                        spacing: 20
                        Text {
                          text: "WI-FI"
                          color: "#dcdcdc"
                          horizontalAlignment: Label.AlignLeft
                          verticalAlignment: Label.AlignTop
                          Layout.minimumWidth: 80
                          Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                        }
                        Switch { checked: true }
                    }
                    RowLayout {
                        spacing: 20
                        Text {
                          text: "蓝牙"
                          color: "#dcdcdc"
                          horizontalAlignment: Label.AlignLeft
                          verticalAlignment: Label.AlignTop
                          Layout.minimumWidth: 80
                          Layout.alignment: Qt.AlignTop | Qt.AlignLeft
                        }
                        Switch { checked: false }
                    }
                }

                Item {
                    Layout.fillWidth: true
                }
            }

            Item {
                Layout.fillHeight: true
            }
        }
    }

    FolderDialog {
        id: folderDialog
        folder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
    }
}
